package com.ricchieri.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.ricchieri.dao.interf.IOperationDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.filter.OperationFilter;
import com.ricchieri.model.Operation;
import com.ricchieri.service.interf.IOperationService;

@Transactional(readOnly = true)
public class OperationService implements IOperationService, Serializable {
	private static final long serialVersionUID = -1780396600212941867L;
	IOperationDao operationDao;
	
	@Override
	@Transactional(readOnly = true)
	public List<Operation> getAllOperations() {
		BasicFilter filter = new BasicFilter();
		return operationDao.getAllOperations(filter);
	}

	public IOperationDao getOperationDao() {
		return operationDao;
	}

	public void setOperationDao(IOperationDao operationDao) {
		this.operationDao = operationDao;
	}
	
	@Override
	@Transactional(readOnly = false)
	public void addOperation(Operation operation){
		operationDao.add(operation);
	}
	
	@Override
	public List<Operation> getAllOperationPaginatedByFilter(
			OperationFilter operationFilter, int startRecord) {
		return operationDao.getAllOperationPaginatedByFilter(operationFilter, startRecord);
	}

	@Override
	public int getAllOperationCountByFilter(OperationFilter operationFilter) {
		return operationDao.getAllOperationCountByFilter(operationFilter);
	}

	@Override
	@Transactional(readOnly = false)
	public void updateOperation(Operation operation) {
		operationDao.update(operation);
	}
}
